package com.symone.crawler.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Log {

    private Class clazz;
    private Logger logger;
    private static DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");

    public Log(Class clazz) {
        this.clazz = clazz;
        this.logger = LoggerFactory.getLogger(clazz);
    }

    public void info(String msg){
        System.out.println( dateFormatter.format(new Date())
                + " INFO [" + this.clazz.getName()
                + "] " + Thread.currentThread().getName()
                + " :" + msg );
        this.logger.info(msg);
    }

    public void error(String msg){
        System.out.println( dateFormatter.format(new Date())
                + " ERROR [" + this.clazz.getName()
                + "] " + Thread.currentThread().getName()
                + " :" + msg );
        this.logger.error(msg);
    }

    public void debug(String msg){
        System.out.println( dateFormatter.format(new Date())
                + " DEBUG [" + this.clazz.getName() + "] "
                + Thread.currentThread().getName()
                + " :" + msg );
        this.logger.debug(msg);
    }
}
